package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author hu
 * @date 2025/5/22
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品ID查询套餐的ID
     *
     * @param dishIds
     * @return
     */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 批量插入套餐菜品
     *
     * @param setmealDishes
     */
    void insertSetmealDishBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐ID获取所有的菜品
     *
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId};")
    List<SetmealDish> getDishsById(@Param("setmealId") Long setmealId);

    void deleteSetmealDishBatch(Long setmealId);


    /**
     * 根据套餐ID删除关联的菜品
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(@Param("setmealId") Long setmealId);
}
